var Loading = (function() {
	"use strict";
	
	var elem ={};
	var that = {};

	that.init = function(options) {
		elem = $(options.selector);
	};

	that.show = function() {
		elem.modal('show');
	};
	
	that.hide = function() {
		elem.modal('hide');
	};
	
	that.wait = function(x, fn) {
		if ( jQuery.isFunction(fn) )
			fn();
		var dfd = $.Deferred();
		setTimeout(function() {
			dfd.resolve();
		}, x);
		return dfd.promise();	
	};
	
	that.link = function(link) {
		elem.modal('show');
		$.when(Loading.wait(500)).done(function(){
			location.href=link;
		});
	};
	
	that.paging = function(page, targetForm) {
		elem.modal('show');
		$.when(Loading.wait(500)).done(function(){
			$("#currentPage").val(page);
			$("#"+targetForm).submit();
		});
	};

	return that;
}());